home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / dejagnu.lha / dejagnu-1.0.1 / tcl / tests / linsert.test < prev    next >
Text File  |  1993-02-14  |  3KB  |  75 lines

  1. # Commands covered:  linsert
  2. #
  3. # This file contains a collection of tests for one or more of the Tcl
  4. # built-in commands.  Sourcing this file into Tcl runs the tests and
  5. # generates output for errors.  No output means no errors were found.
  6. #
  7. # Copyright 1991 Regents of the University of California
  8. # Permission to use, copy, modify, and distribute this
  9. # software and its documentation for any purpose and without
  10. # fee is hereby granted, provided that this copyright notice
  11. # appears in all copies.  The University of California makes no
  12. # representations about the suitability of this software for any
  13. # purpose.  It is provided "as is" without express or implied
  14. # warranty.
  15. #
  16. # $Header: /rel/cvsfiles/devo/tcl/tests/linsert.test,v 1.1.1.1 1992/11/07 04:46:57 zoo Exp $ (Berkeley)
  17.  
  18. if {[string compare test [info procs test]] == 1} then {source defs}
  19.  
  20. test linsert-1.1 {linsert command} {
  21.     linsert {1 2 3 4 5} 0 a
  22. } {a 1 2 3 4 5}
  23. test linsert-1.2 {linsert command} {
  24.     linsert {1 2 3 4 5} 1 a
  25. } {1 a 2 3 4 5}
  26. test linsert-1.3 {linsert command} {
  27.     linsert {1 2 3 4 5} 2 a
  28. } {1 2 a 3 4 5}
  29. test linsert-1.4 {linsert command} {
  30.     linsert {1 2 3 4 5} 3 a
  31. } {1 2 3 a 4 5}
  32. test linsert-1.5 {linsert command} {
  33.     linsert {1 2 3 4 5} 4 a
  34. } {1 2 3 4 a 5}
  35. test linsert-1.6 {linsert command} {
  36.     linsert {1 2 3 4 5} 5 a
  37. } {1 2 3 4 5 a}
  38. test linsert-1.7 {linsert command} {
  39.     linsert {1 2 3 4 5} 2 one two \{three \$four
  40. } {1 2 one two \{three {$four} 3 4 5}
  41. test linsert-1.8 {linsert command} {
  42.     linsert {\{one \$two \{three \ four \ five} 2 a b c
  43. } {\{one \$two a b c \{three \ four \ five}
  44. test linsert-1.9 {linsert command} {
  45.     linsert {{1 2} {3 4} {5 6} {7 8}} 2 {x y} {a b}
  46. } {{1 2} {3 4} {x y} {a b} {5 6} {7 8}}
  47. test linsert-1.10 {linsert command} {
  48.     linsert {} 2 a b c
  49. } {a b c}
  50. test linsert-1.11 {linsert command} {
  51.     linsert {} 2 {}
  52. } {{}}
  53. test linsert-1.12 {linsert command} {
  54.     linsert {a b "c c" d e} 3 1
  55. } {a b "c c" 1 d e}
  56. test linsert-1.13 {linsert command} {
  57.     linsert { a b c d} 0 1 2
  58. } {1 2  a b c d}
  59. test linsert-1.14 {linsert command} {
  60.     linsert {a b c {d e f}} 4 1 2
  61. } {a b c {d e f} 1 2}
  62.  
  63. test linsert-2.1 {linsert errors} {
  64.     list [catch linsert msg] $msg
  65. } {1 {wrong # args: should be "linsert list index element ?element ...?"}}
  66. test linsert-2.2 {linsert errors} {
  67.     list [catch {linsert a b} msg] $msg
  68. } {1 {wrong # args: should be "linsert list index element ?element ...?"}}
  69. test linsert-2.3 {linsert errors} {
  70.     list [catch {linsert a 12x 2} msg] $msg
  71. } {1 {expected integer but got "12x"}}
  72. test linsert-2.4 {linsert errors} {
  73.     list [catch {linsert \{ 12 2} msg] $msg
  74. } {1 {unmatched open brace in list}}
  75.